$OpenBSD: patch-Makefile,v 1.2 2015/07/16 23:18:23 ajacoutot Exp $
--- Makefile.orig	Thu Feb 12 14:14:33 2015
+++ Makefile	Fri Jul 17 01:17:37 2015
@@ -20,14 +20,14 @@
 
 include Makefile.cfg
 
-export CC = gcc -pthread
-export CFLAGS += -I. -Wall -Os -ggdb -D_GNU_SOURCE -fPIC
-export LDLIBS += -lncursesw
+export CC ?= gcc -pthread
+export CFLAGS += -I. -Wall -ggdb -D_XOPEN_SOURCE_EXTENDED -fPIC -I${LOCALBASE}/include
+export LDLIBS += -lpthread -lncursesw -L${LOCALBASE}/lib -liconv -Wl,-R${LOCALBASE}/lib
 
-SONAME  := libstfl.so.0
+SONAME  := libstfl.so.${LIBstfl_VERSION}
 VERSION := 0.24
 
-all: libstfl.so.$(VERSION) libstfl.a example
+all: $(SONAME) libstfl.a example
 
 example: libstfl.a example.o
 
@@ -37,9 +37,9 @@ libstfl.a: public.o base.o parser.o dump.o style.o bin
 	ar qc $@ $^
 	ranlib $@
 
-libstfl.so.$(VERSION): public.o base.o parser.o dump.o style.o binding.o iconv.o \
+$(SONAME): public.o base.o parser.o dump.o style.o binding.o iconv.o \
                        $(patsubst %.c,%.o,$(wildcard widgets/*.c))
-	$(CC) -shared -Wl,-soname,$(SONAME) -o $@ $(LDLIBS) $^
+	$(CC) $(CFLAGS) -shared -o $@ $(LDLIBS) $^
 
 clean:
 	rm -f libstfl.a example core core.* *.o Makefile.deps
@@ -53,8 +53,8 @@ clean:
 	rm -f stfl.pc libstfl.so libstfl.so.*
 
 Makefile.deps: *.c widgets/*.c *.h
-	$(CC) -I. -MM *.c > Makefile.deps_new
-	$(CC) -I. -MM widgets/*.c | sed 's,^wt_[^ ]*\.o: ,widgets/&,' >> Makefile.deps_new
+	$(CC) $(CFLAGS) -I. -MM *.c > Makefile.deps_new
+	$(CC) $(CFLAGS) -I. -MM widgets/*.c | sed 's,^wt_[^ ]*\.o: ,widgets/&,' >> Makefile.deps_new
 	mv -f Makefile.deps_new Makefile.deps
 
 install: all stfl.pc
